﻿<%@ Page Title="Мерни единици" Language="C#" MasterPageFile="~/LeftColumn.Master" AutoEventWireup="true" CodeBehind="CreateMeasure.aspx.cs" Inherits="Supermarket.Web.CreateMeasure" %>
<asp:Content ID="Content" ContentPlaceHolderID="RightContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="upMeasures" runat="server">
        <ContentTemplate>
            <asp:GridView ID="GridViewMeasures" runat="server" AllowPaging="True" 
                AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" 
                BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" 
                DataKeyNames="MeasureId" DataSourceID="odsMeasures" PageSize="15">
                <Columns>
                    <asp:CommandField CancelText="Отказ" DeleteText="Изтрий" EditText="Редактирай" 
                        InsertText="Добави" NewText="Нов" ShowDeleteButton="True" ShowEditButton="True" 
                        UpdateText="Обнови" />
                    <asp:BoundField DataField="MeasureName" HeaderText="Мерна единица" 
                        SortExpression="MeasureName" />
                    <asp:BoundField DataField="MeasureCode" HeaderText="Код" 
                        SortExpression="MeasureCode" />
                </Columns>
                <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
                <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
                <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
                <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#FFF1D4" />
                <SortedAscendingHeaderStyle BackColor="#B95C30" />
                <SortedDescendingCellStyle BackColor="#F1E5CE" />
                <SortedDescendingHeaderStyle BackColor="#93451F" />
            </asp:GridView>
        </ContentTemplate>
    </asp:UpdatePanel>
    <br />
    <asp:UpdatePanel ID="upAdd" runat="server">
        <ContentTemplate>
            <asp:LinkButton ID="LinkButtonAdd" Text="Добави нова мерна единица" 
                runat="server" onclick="LinkButtonAdd_Click" />
            <asp:FormView ID="fvMeasure" runat="server" DefaultMode="Insert" 
                DataSourceID="odsMeasures" BackColor="LightGoldenrodYellow" 
                BorderColor="Tan" BorderWidth="1px" Visible="false">                
                <InsertItemTemplate>
                    <table>
                        <tr>
                            <td><strong>Мерна единица:</strong></td>
                            <td><asp:TextBox ID="TextBoxMeasureName" runat="server" Text='<%# Bind("MeasureName") %>' /></td>
                        </tr>
                        <tr>
                            <td><strong>Код:</strong></td>
                            <td><asp:TextBox ID="TextBoxMeasureCode" runat="server" Text='<%# Bind("MeasureCode") %>' /></td>
                        </tr>
                        <tr>
                            <td colspan="2"><asp:LinkButton ID="LinkButtonSubmit" runat="server" Text="Добави" CommandName="Insert" 
                                                            onclick="LinkButtonSubmit_Click"/></td>
                        </tr>
                        
                    </table>
                </InsertItemTemplate>
            </asp:FormView>
        </ContentTemplate>
    </asp:UpdatePanel>

    <asp:ObjectDataSource ID="odsMeasures" runat="server" DeleteMethod="Delete" 
        InsertMethod="CreateMeasure" SelectMethod="GetAllMeasures" 
        TypeName="Supermarket.Bll.MeasureManager" UpdateMethod="Update">
        <DeleteParameters>
            <asp:Parameter Name="measureId" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="measureName" Type="String" />
            <asp:Parameter Name="measureCode" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="measureId" Type="Int32" />
            <asp:Parameter Name="measureName" Type="String" />
            <asp:Parameter Name="measureCode" Type="String" />
        </UpdateParameters>
    </asp:ObjectDataSource>
</asp:Content>
